package org.feidao.chapter64.producer;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.UUID;
/**
 * Created by linghufeixia on 2022-12-28.
 * direct service
 */
@Slf4j
@Service
public class DirectService {
    String routeKey = "direct_queue_A";

    @Autowired
    private RabbitTemplate rabbitTemplate;

    public void sendData(String data) {
        CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString());
        log.info("------------direct producer begin------------");
        rabbitTemplate.convertAndSend(routeKey, data);
        log.info("routeKey:"+routeKey);
        log.info("send data:"+data);
        log.info("------------direct producer end------------");
    }
}
